#
#2008 Julka Lipkova
#

import pygtk
pygtk.require('2.0')
import gtk
import random

from glyph import Glyph

class GlyphDB ():
    def __init__(self):
        f = open( 'data/index.txt', 'r' )
        n = int(f.readline())
        self.ids = map( int, f.readline().split() )
        self.glyphs = {}
        for i in range(n):
            self.glyphs[self.ids[i]] = Glyph()
            self.glyphs[self.ids[i]].loadFromFile(self.idToFile(self.ids[i]))
        f.close()

    def idToFile(self, id):
        filename = 'data/' + repr(id) + '.dat'
        return filename

    def getGlyphByID(self, id):
        return self.glyphs[id]

    def getLinesByID(self, id):
        return self.glyphs[id].lines

    def getRandomID(self):
        return random.choice(self.ids)

glyphDB = GlyphDB()

# vim: set ts=4 sw=4 sts=4 et :
